// pages/myorder/index.js
const SERVER = require('../../utils/index');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isActive:0,
    activeList:['全部','待付款','已付款']
  },
  todetail(){
    wx.navigateTo({
      url: '/pages/orderDetail/index',
    })
  },
  changeIndex(e){
    const index = e.currentTarget.dataset.index
    console.log(index)
    if(index==1){
      var that=this
    
    wx.request({//首页数据
      url: '' + SERVER.SERVER_DIMAIN + '/customer/order/findOrderInfo', 
      data: {
        
          "current":1,//当前页
          "findStatus":"1",//“”全部 /1待付款/2已付款
          "size":500,//每页显示条数
      
      
      },
      header: {
        'content-type': 'application/json' ,
        "TENANT-ID":"2",
        "Connection":'Keep-alive',
        "Accept-Encoding":'gzip,deflate,br',
        "Authorization":"Bearer "+wx.getStorageSync('token'),
        "DEVICE_TYPE":'IOS'
      },
      method: 'post',
      success: function (res) {
        console.log(res)
        that.setData({
          list:res.data.data.records
        })
        
        // that.setData({
        //   list:res.data.data
        // })
        
     
       
      }
    });
    }else if(index==2){
      var that=this
    
      wx.request({//首页数据
        url: '' + SERVER.SERVER_DIMAIN + '/customer/order/findOrderInfo', 
        data: {
          
            "current":1,//当前页
            "findStatus":"2",//“”全部 /1待付款/2已付款
            "size":500,//每页显示条数
        
        
        },
        header: {
          'content-type': 'application/json' ,
          "TENANT-ID":"2",
          "Connection":'Keep-alive',
          "Accept-Encoding":'gzip,deflate,br',
          "Authorization":"Bearer "+wx.getStorageSync('token'),
          "DEVICE_TYPE":'IOS'
        },
        method: 'post',
        success: function (res) {
          console.log(res)
          that.setData({
            list:res.data.data.records
          })
          
          // that.setData({
          //   list:res.data.data
          // })
          
       
         
        }
      });
    }else{
      var that=this
    
      wx.request({//首页数据
        url: '' + SERVER.SERVER_DIMAIN + '/customer/order/findOrderInfo', 
        data: {
          
            "current":1,//当前页
            "findStatus":"",//“”全部 /1待付款/2已付款
            "size":500,//每页显示条数
        
        
        },
        header: {
          'content-type': 'application/json' ,
          "TENANT-ID":"2",
          "Connection":'Keep-alive',
          "Accept-Encoding":'gzip,deflate,br',
          "Authorization":"Bearer "+wx.getStorageSync('token'),
          "DEVICE_TYPE":'IOS'
        },
        method: 'post',
        success: function (res) {
          console.log(res)
          that.setData({
            list:res.data.data.records
          })
          
          // that.setData({
          //   list:res.data.data
          // })
          
       
         
        }
      });
    }
    this.setData({isActive:index})

  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options.index)
    this.setData({
      isActive:options.index
    })
    var that=this
    
    wx.request({//首页数据
      url: '' + SERVER.SERVER_DIMAIN + '/customer/order/findOrderInfo', 
      data: {
        
          "current":1,//当前页
          "findStatus":"",//“”全部 /1待付款/2已付款
          "size":500,//每页显示条数
      
      
      },
      header: {
        'content-type': 'application/json' ,
        "TENANT-ID":"2",
        "Connection":'Keep-alive',
        "Accept-Encoding":'gzip,deflate,br',
        "Authorization":"Bearer "+wx.getStorageSync('token'),
        "DEVICE_TYPE":'IOS'
      },
      method: 'post',
      success: function (res) {
        console.log(res)
        that.setData({
          list:res.data.data.records
        })
        
        // that.setData({
        //   list:res.data.data
        // })
        
     
       
      }
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})